home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / util / cli / gengui21.lha / Gengui2.1 / Examples / test_locale.c < prev    next >
C/C++ Source or Header  |  1995-10-11  |  3KB  |  113 lines

  1.  
  2. #include <stdlib.h>
  3. #include <proto/intuition.h>
  4. #include <intuition/intuition.h>
  5. #include <proto/exec.h>
  6. #include <proto/graphics.h>
  7. #include <graphics/text.h>
  8. #include <stdio.h>
  9.  
  10. #include <libraries/locale.h>
  11. #include <proto/locale.h>
  12.  
  13. #ifndef GUINAME
  14. #include "test.h"
  15. #else
  16. #include GUINAME
  17. #endif
  18.  
  19. struct IntuitionBase *IntuitionBase;
  20. struct GfxBase *GfxBase;
  21. struct Library *GadToolsBase;
  22. struct Library *UtilityBase;
  23. struct Window *win;
  24. struct TextFont *font=NULL;
  25.  
  26. struct Library *LocaleBase;
  27. struct Catalog *Catalog;
  28.  
  29. void quit(char *e)
  30. {
  31.    if(e) fprintf(stderr,"%s\n",e);
  32.  
  33.    if(font) CloseFont(font); /* Important !!! */
  34.    if(win) CloseWindow(win);
  35.    if(Catalog) CloseCatalog(Catalog);
  36.    if(LocaleBase) CloseLibrary(LocaleBase);
  37.    if(UtilityBase) CloseLibrary(UtilityBase);
  38.    if(GadToolsBase) CloseLibrary(GadToolsBase);
  39.    if(GfxBase) CloseLibrary((struct Library *)GfxBase);
  40.    if(IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
  41.  
  42.    if(e) exit(EXIT_FAILURE);
  43.    exit(EXIT_SUCCESS);
  44. }
  45.  
  46. main()
  47. {
  48.    struct IntuiMessage *msg;
  49.    int run=1;
  50.  
  51.    if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",36)))
  52.       quit("No intuition.library V36");
  53.  
  54.    if(!(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",36)))
  55.       quit("No graphics.library V36");
  56.  
  57.    if(!(GadToolsBase=OpenLibrary("gadtools.library",36)))
  58.       quit("No gadtools.library V36");
  59.  
  60.    if(!(UtilityBase=OpenLibrary("utility.library",36)))
  61.       quit("No utility.library V36");
  62.  
  63.  
  64.    if(LocaleBase=OpenLibrary("locale.library",38)) {
  65.       Catalog=OpenCatalog(NULL,GUI_CATALOG,OC_BuiltInLanguage,"english",
  66.                                            OC_Version,1,TAG_DONE);
  67.    }
  68.  
  69.  
  70.    if(!(win=OpenWindowTags(NULL,
  71.          WA_Left,160,WA_Top,20,
  72.          WA_Width,320,WA_Height,200,
  73.          WA_Title,TITLE,
  74.          WA_IDCMP,BUTTONIDCMP|IDCMP_CLOSEWINDOW|SLIDERIDCMP|
  75.                   IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW|IDCMP_SIZEVERIFY,
  76.          WA_Flags,WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET
  77.                      |WFLG_SIMPLE_REFRESH
  78.                      |WFLG_CLOSEGADGET|WFLG_ACTIVATE,
  79.          WA_MinWidth,0,WA_MinHeight,0,
  80.          WA_MaxWidth,-1,WA_MaxHeight,-1,
  81.          TAG_DONE ))) quit("Cannot open window");
  82.  
  83.    if(GG_SmartRenderGui(win,&TestPro,&font)) quit("Cannot render GUI");
  84.  
  85.    while(run) {
  86.       WaitPort(win->UserPort);
  87.       while(msg=GG_GetIMsg(win->UserPort)) {
  88.          switch(msg->Class) {
  89.             case IDCMP_CLOSEWINDOW: run--;
  90.                                     break;
  91.             case IDCMP_NEWSIZE:     GG_ResizeGui(&TestPro);
  92.                                     break;
  93.             case IDCMP_SIZEVERIFY:  GG_BeginResizeGui(&TestPro);
  94.                                     break;
  95.             case IDCMP_REFRESHWINDOW:
  96.                                     GG_BeginRefresh(&TestPro);
  97.                                     GG_RefreshGui(&TestPro);
  98.                                     GG_EndRefresh(&TestPro,TRUE);
  99.                                     break;
  100.             case IDCMP_GADGETUP:
  101.                                     break;
  102.          }
  103.          GG_ReplyIMsg(msg);
  104.       }
  105.    }
  106.    GG_FreeGui(&TestPro);
  107.  
  108.    quit(NULL);
  109. }
  110.  
  111.  
  112.  
  113.